package com.xuecheng.system.service.impl;

import com.xuecheng.api.system.model.dto.CourseCategoryDTO;
import com.xuecheng.system.convert.CourseCategoryConvert;
import com.xuecheng.system.entity.CourseCategory;
import com.xuecheng.system.entity.ext.CourseCategoryNode;
import com.xuecheng.system.mapper.CourseCategoryMapper;
import com.xuecheng.system.service.CourseCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 课程分类 服务实现类
 * </p>
 *
 * @author itcast
 */
@Slf4j
@Service
public class CourseCategoryServiceImpl extends ServiceImpl<CourseCategoryMapper, CourseCategory> implements CourseCategoryService {

    @Override
    public List<CourseCategoryDTO> queryTreeNodes() {
        CourseCategoryMapper baseMapper = this.getBaseMapper();
        List<CourseCategoryNode> courseCategoryNodes = baseMapper.selectTreeNodes();
        List<CourseCategoryDTO> courseCategoryDTOS = CourseCategoryConvert.INSTANCE.entitys2Dtos(courseCategoryNodes);
        return courseCategoryDTOS;
    }
}
